<template >
	<div>
		<div v-for="(e,index) in list" class="floor">
			<mt-switch v-model="value[index]"></mt-switch>
			<img :src="e.thumb_path" alt=""/>
			<div>
				<h4>{{e.title}}</h4>
				<span>{{e.sell_price}}</span>
				<inputNum></inputNum>
				<a href="javascript:;" @click="remove(e.id)">删除</a>
			</div>
		</div>

	</div>
</template>
<script type="text/ecmascript-6">
	import {getItem,setItem,gaibian,remove} from './../account/localstorage.js'
	import inputNum from './../account/inputNum.vue'
	import { Switch } from 'mint-ui';

	export default {
		components:{
			inputNum
		},
		data(){
			return{
				value:[],
				data:'',
				list:[]
			}
		},
		created(){
			this.getData()
		},
		methods:{
			getData(){
				var a = gaibian() //获取localstroage传回来的值

				var str = ''

				for(var k in a ){
					str += k + ','
				}

				str = str.substr(0,str.length-1) || 0,1

				//console.log(str);


				var url = 'http://vue.studyit.io/api/goods/getshopcarlist/' + str

				this.$http.get(url).then(function(data){
					console.log(data);
					this.list = data.body.message
				})
			},
			remove(id){
				remove(id)
				this.getData()
			}
		}
	}

</script>
<style scoped>
	.floor{
		height: 100px;
		display: flex;
		justify-content: space-around;
		padding: 5px;
		box-sizing: border-box;
		border: 1px solid #eeeeee;
	}

	.floor img{
		width: 100px;
	}
</style>
